//
//  BCRegisterView.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/14.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCRegisterView.h"

@implementation BCRegisterView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    self.backgroundColor = [UIColor colorWithRed:0.957  green:0.957  blue:0.957 alpha:1];
    UIView *headView = [[UIView alloc] init];
    headView.backgroundColor = [UIColor colorWithRed:1  green:1  blue:1 alpha:1];
    UILabel *phNumLab = [[UILabel alloc] init];
    phNumLab.text = @"手机号:";
    phNumLab.font = [UIFont boldSystemFontOfSize:18];
    phNumLab.textColor = [UIColor colorWithRed:0.412  green:0.638  blue:0.478 alpha:1];
    UILabel *confNumLab = [[UILabel alloc] init];
    confNumLab.text = @"验证码:";
    confNumLab.font = [UIFont boldSystemFontOfSize:18];
    confNumLab.textColor = [UIColor colorWithRed:0.412  green:0.638  blue:0.478 alpha:1];
    UILabel *passWordLab = [[UILabel alloc] init];
    passWordLab.text = @"设置密码:";
    passWordLab.font = [UIFont boldSystemFontOfSize:18];
    passWordLab.textColor = [UIColor colorWithRed:0.412  green:0.638  blue:0.478 alpha:1];
    
    self.phoneNum = [[UITextField alloc] init];
    self.phoneNum.placeholder = @"请输入手机号";
    
    self.passWord = [[UITextField alloc] init];
    self.passWord.placeholder = @"请输入8位以上字符";
    self.passWord.secureTextEntry = YES;
    self.confirmNum = [[UITextField alloc] init];
    self.confirmNum.placeholder = @"请输入验证码";
    self.nextStepBut = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.nextStepBut setTitle:@"下一步" forState:UIControlStateNormal];
    self.nextStepBut.backgroundColor = [UIColor colorWithRed:0.325  green:0.564  blue:0.386 alpha:1];
    self.nextStepBut.tintColor = [UIColor whiteColor];
    self.nextStepBut.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    self.getConfirm = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.getConfirm setTitle:@"获取验证码" forState:UIControlStateNormal];
    self.getConfirm.backgroundColor = [UIColor colorWithRed:0.325  green:0.564  blue:0.386 alpha:1];
    self.getConfirm.tintColor = [UIColor whiteColor];
    self.getConfirm.titleLabel.font = [UIFont boldSystemFontOfSize:13];
    self.getConfirm.layer.cornerRadius = 10;
    [self addSubview:headView];
    [self addSubview:self.nextStepBut];
    
    
    
    
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.mas_equalTo(0);
        make.top.mas_equalTo(64);
        make.height.mas_equalTo((self.frame.size.height * .22));
    }];
    [self.nextStepBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(headView.mas_bottom).with.offset(45);
        make.centerX.equalTo(self);
        make.width.mas_equalTo((self.frame.size.width * .52));
        make.height.mas_equalTo((self.frame.size.height * .07));
    }];
    
    
    
    [headView addSubview:phNumLab];
    [headView addSubview:confNumLab];
    [headView addSubview:passWordLab];
    
    [headView addSubview:self.phoneNum];
    [headView addSubview:self.confirmNum];
    [headView addSubview:self.passWord];
    [headView addSubview:self.getConfirm];
    
    [phNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo((self.frame.size.height * .22 / 3));
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(29);
        make.width.mas_equalTo(100);
    }];
    [self.phoneNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.and.top.equalTo(phNumLab);
        make.left.mas_equalTo(phNumLab.mas_right);
        make.right.mas_equalTo(-100);
        
    }];
    [self.getConfirm mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(28);
        make.top.mas_equalTo(19);
        make.width.mas_equalTo(70);
        make.right.mas_equalTo(-16);
        
    }];
    
    
    [confNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.and.height.left.and.right.equalTo(phNumLab);
        make.top.mas_equalTo(phNumLab.mas_bottom);
    }];
    [self.confirmNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.and.top.equalTo(confNumLab);
        make.left.mas_equalTo(confNumLab.mas_right);
        make.right.mas_equalTo(0);

        
    }];
    
    
    [passWordLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.and.height.left.and.right.equalTo(phNumLab);
        make.top.mas_equalTo(confNumLab.mas_bottom);
    }];
    [self.passWord mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.and.top.equalTo(passWordLab);
        make.left.mas_equalTo(passWordLab.mas_right);
        make.right.mas_equalTo(0);
   
    }];
    
    
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    [self.confirmNum resignFirstResponder];
    [self.phoneNum resignFirstResponder];
    [self.passWord resignFirstResponder];
    return YES;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
    [self.confirmNum resignFirstResponder];
    [self.phoneNum resignFirstResponder];
    [self.passWord resignFirstResponder];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
